package com.way.controller;

import com.way.common.core.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@Tag(name = "演示服务")
@RequestMapping("/demo")
@RestController
public class DemoController {

    @Operation(summary = "Hello World")
    @Parameters(
            @Parameter(name = "name", description = "姓名", required = false, in = ParameterIn.PATH)
    )
    @GetMapping(value = {"/hello", "/hello/{name}"})
    public R<String> hello(@PathVariable(name = "name") Optional<String> name) {
        return R.ok("Hello " + name.orElse("World"));
    }

}
